home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed fades ƒ / Mr. Do fade reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  3.6 KB  |  173 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Mr. Do fade reversed.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define        BoxSize    4
  32. #define CorrectTime 1
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34. #define theWindowWidth (boundsRect.right-boundsRect.left)
  35.  
  36. pascal short MrDoFadeReversed(Rect boundsRect, Pattern *thePattern);
  37.  
  38. /* 25 regions, in a 5 x 5 grid.  Go around to each region in a spiral pattern,
  39.    starting with the center square, and alternatively scroll it up or down. */
  40.    
  41. pascal short MrDoFadeReversed(Rect boundsRect, Pattern *thePattern)
  42. {
  43.     int            x, y;
  44.     int            vgap,hgap;
  45.     Rect        dest;
  46.     Rect        bounds[25];
  47.     Boolean        everyOther;
  48.     
  49.     vgap=theWindowHeight/5;
  50.     hgap=theWindowWidth/5;
  51.     
  52.     for (x=0; x<25; x++)
  53.     {
  54.         switch (x)
  55.         {
  56.             case 0:
  57.             case 1:
  58.             case 2:
  59.             case 3:
  60.             case 4:
  61.                 bounds[x].top=0;
  62.                 break;
  63.             case 15:
  64.             case 16:
  65.             case 17:
  66.             case 18:
  67.             case 5:
  68.                 bounds[x].top=vgap;
  69.                 break;
  70.             case 14:
  71.             case 23:
  72.             case 24:
  73.             case 19:
  74.             case 6:
  75.                 bounds[x].top=vgap*2;
  76.                 break;
  77.             case 13:
  78.             case 22:
  79.             case 21:
  80.             case 20:
  81.             case 7:
  82.                 bounds[x].top=vgap*3;
  83.                 break;
  84.             case 12:
  85.             case 11:
  86.             case 10:
  87.             case 9:
  88.             case 8:
  89.                 bounds[x].top=vgap*4;
  90.                 break;
  91.         }
  92.         switch (x)
  93.         {
  94.             case 0:
  95.             case 15:
  96.             case 14:
  97.             case 13:
  98.             case 12:
  99.                 bounds[x].left=0;
  100.                 break;
  101.             case 1:
  102.             case 16:
  103.             case 23:
  104.             case 22:
  105.             case 11:
  106.                 bounds[x].left=hgap;
  107.                 break;
  108.             case 2:
  109.             case 17:
  110.             case 24:
  111.             case 21:
  112.             case 10:
  113.                 bounds[x].left=hgap*2;
  114.                 break;
  115.             case 3:
  116.             case 18:
  117.             case 19:
  118.             case 20:
  119.             case 9:
  120.                 bounds[x].left=hgap*3;
  121.                 break;
  122.             case 4:
  123.             case 5:
  124.             case 6:
  125.             case 7:
  126.             case 8:
  127.                 bounds[x].left=hgap*4;
  128.                 break;
  129.         }
  130.         bounds[x].bottom=bounds[x].top+vgap;
  131.         bounds[x].right=bounds[x].left+hgap;
  132.         OffsetRect(&(bounds[x]), boundsRect.left, boundsRect.top);
  133.     }
  134.     
  135.     for (y=24; y>=0; y--)
  136.     {        
  137.         if (!(y%2))   /* these scroll up */
  138.         {
  139.             dest=bounds[y];
  140.             dest.top=dest.bottom-BoxSize;
  141.             
  142.             for (x=bounds[y].bottom-bounds[y].top-BoxSize; x>0; x-=BoxSize)
  143.             {
  144.                 StartTiming();
  145.                 ScrollRect(&bounds[y], 0, -BoxSize, 0L);
  146.                 FillRect(&dest, *thePattern);
  147.                 if (everyOther)
  148.                     TimeCorrection(CorrectTime);
  149.                 everyOther=!everyOther;
  150.             }
  151.         }
  152.         else    /* these scroll down */
  153.         {
  154.             dest=bounds[y];
  155.             dest.bottom=dest.top+BoxSize;
  156.             
  157.             for(x = bounds[y].bottom-bounds[y].top-BoxSize; x > 0; x -= BoxSize)
  158.             {
  159.                 StartTiming();
  160.                 ScrollRect(&bounds[y], 0, BoxSize, 0L);
  161.                 FillRect(&dest, *thePattern);
  162.                 if (everyOther)
  163.                     TimeCorrection(CorrectTime);
  164.                 everyOther=!everyOther;
  165.             }
  166.         }
  167.         
  168.         FillRect(&bounds[y], *thePattern);
  169.     }
  170.     
  171.     return 0;
  172. }
  173.